Field (computer science)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
In data hierarchy, a field (data field) is a variable in a record.cite-ref-pascal-p42-quoted-1-0[1] A record, also known as a data structure, allows logically related data to be identified by a single name. Identifying related data as a single group is central to the construction of understandable computer programs.cite-ref-cpl-p169-quote1-2-0[2] The individual fields in a record may be accessed by name, just like any variable in a computer program.cite-ref-cpl-p169-3-0[3]
Each field in a record has two components. One component is the field's datatype declaration. The other component is the field's identifier.cite-ref-pascal-p42-4-0[4]
Contents
• See also
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Memory fields
Fields may be stored in random access memory (RAM). The following Pascal record definition has three field identifiers: firstName, lastName, and age. The two name fields have a datatype of an array of character. The age field has a datatype of integer.
type PersonRecord =
record
lastName : array [ 1 .. 20 ] of Char;
firstName : array [ 1 .. 20 ] of Char;
age : Integer
end;
var alice : PersonRecord;
alice.firstName := 'Alice';
public class PersonRecord
{
private String firstName;
private String lastName;
private int age;
}
File fields
Fields may be stored in a random access file.cite-ref-cpl-p169-quote2-7-0[7] A file may be written to or read from in an arbitrary order. To accomplish the arbitrary access, the operating system provides a method to quickly seek around the file.cite-ref-upe-p207-quote-8-0[8] Once the disk head is positioned at the beginning of a record, each file field can be read into its corresponding memory field.
File fields are the main storage structure in the Indexed Sequential Access Method (ISAM). In relational database theory, the term field has been replaced with the terms column and attribute.cite-ref-did-p5-quote-9-0[9]
See also
• Class variable – Variable defined in a class whose objects all possess the same copy
• Mutator method – Computer science method
References
cite-note-cpl-p169-quote2-77. ↑ citerefwilsonclark2001Wilson, Leslie B.; Clark, Robert G. (2001). Comparative Programming Languages, Third Edition. Addison-Wesley. p. 169. ISBN 0-201-71012-9. The original use of records was in languages like COBOL, where they were used to define the structure of records held in a file.